<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>   
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}" /> 
<c:set var="date" value="" />
<c:set var="count" value="1" />
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width" />
	<title>성공회대학교 전자계산소 장애처리 접수</title>
	<link media="all" rel="stylesheet" href="${contextPath}/css/index.css" />
	<script type="text/javascript" charset="utf-8" src="${contextPath}/js/calendar_beans_v2.0.js"></script>
	<script type="text/javascript" charset="utf-8" src="${contextPath}/js/common/jquery-1.8.1.js"></script>
	<script type="text/javascript"> 
	var contextPath = "${contextPath}";
	var year = "${year}"; 
	var month = "${month}";
	var dayOfMonth = "${dayOfMonth}"; 
	$(document).ready(function(){
		/*
		id      :텍스트박스Id   // *필수
		type    :day,mon        // 둘중 하나입력      ,기본값> 일달력 출력
		minYear :xxxx           // 최소년도 4자리 입력  ,기본값> 2000
		maxYear :xxxx           // 최대년도 4자리 입력  ,기본값> 현재년도
		splitKey:'-','/'        // 달력 구분값           ,기본값> '-'
		todayYN :'y','n'        // today 표시             ,기본값> 안보여주기
		iconYN  :'y','n'        // 달력그림표시여부     ,기본값> 안보여주기
		iconUrl :fullUrl 혹은 해당위치 상대경로 url'  ,기본값> jquery 사이트 달력
		*/
		CalAddCss(); // !!제일 상단에 필수!!
		initCal({id:"cal1",type:"day",today:"y",icon:"n"}); 
		//initCal({id:"cal2",type:"mon",today:"y",icon:"y"});
				
	});
	</script> 
</head>
<body>
	
	<div id="top">
		<a href="${contextPath}/index.do" title="성공회대학교 전자계산소 장애처리 접수 메인페이지로 이동">
			<img id="logo_img" src="${contextPath}/img/skhu_logo.jpg" alt="인권과 평화의 대학 성공회대학교" />
		</a>
		<h1 id="top_title">전자계산소<br />장애처리접수</h1>  
	</div>
	
	<div id="left">
	
		<div id="calendar">
			<div id="cal1"></div>
			<a id="reg" href="${contextPath}/fault_handling_reg.do">업무 등록</a>
		</div>
	
		<dl id="untreated" class="wrap">
			<dt class="wrap_title">미처리업무</dt>
			<c:forEach items="${untreatedWorkList}" var="untreatedWork" varStatus="i">
				<c:choose>
					<c:when test="${date == untreatedWork.processDate}">
						<c:set var="count" value="${count + 1}" />
						<c:if test="${i.index == size-1}">
							<dd>
								<a href="${contextPath}/index.do?year=${fn:substring(date, 0, 4)}&month=${fn:substring(date, 4, 6)}&dayOfMonth=${fn:substring(date, 6, 8)}">
									${fn:substring(date, 0, 4)}년 ${fn:substring(date, 4, 6)}월 ${fn:substring(date, 6, 8)}일에 미처리업무 ${count}건이 있습니다.								
								</a>
							</dd>
						</c:if> 
					</c:when> 
					<c:otherwise> 
						<c:if test="${i.index != 0}"> 
							<dd>
								<a href="${contextPath}/index.do?year=${fn:substring(date, 0, 4)}&month=${fn:substring(date, 4, 6)}&dayOfMonth=${fn:substring(date, 6, 8)}">
									${fn:substring(date, 0, 4)}년 ${fn:substring(date, 4, 6)}월 ${fn:substring(date, 6, 8)}일에 미처리업무 ${count}건이 있습니다.								
								</a>
							</dd>
						</c:if>
						<c:set var="date" value="${untreatedWork.processDate}" />
						<c:set var="count" value="1" /> 
						<c:if test="${i.count == size}"> 
							<dd>
								<a href="${contextPath}/index.do?year=${fn:substring(date, 0, 4)}&month=${fn:substring(date, 4, 6)}&dayOfMonth=${fn:substring(date, 6, 8)}">
									${fn:substring(date, 0, 4)}년 ${fn:substring(date, 4, 6)}월 ${fn:substring(date, 6, 8)}일에 미처리업무 ${count}건이 있습니다.								
								</a>
							</dd> 
						</c:if>
					</c:otherwise>
				</c:choose>
			</c:forEach>
		</dl> 
		
		<dl id="hourly" class="wrap">
			<dt class="wrap_title">근무시간별 처리업무</dt>
			<dd>
				<c:forEach items="${dutyHoursList}" var="dutyHours">
					<dl>
						<dt>${dutyHours.dutyHours}</dt>
						<c:forEach items="${faultHandlingList}" var="faultHandling">
							<c:if test="${dutyHours.dutyHoursNo == faultHandling.dutyHoursNo}">
								<dd>
									<a href="${contextPath}/index.do?year=${year}&month=${month}&dayOfMonth=${dayOfMonth}&faultHandlingNo=${faultHandling.faultHandlingNo}">${faultHandling.requestContent}</a> [${faultHandling.processStatus}]
								</dd> 
							</c:if>
						</c:forEach>  
					</dl> 
				</c:forEach> 
			</dd>
		</dl>
		
	</div>
	
		<c:if test="${faultHandling != null}"> 
			<div id="center">
				<dl id="fault_handling_content" class="wrap">
					<dt class="wrap_title">장애처리 내용</dt>
					<dd>처리상태 : ${faultHandling.processStatus}</dd>
					<dd>접수자 : ${faultHandling.receptionistName} (${faultHandling.receptionistContactNumber})</dd>
					<dd>접수일자 : ${fn:substring(faultHandling.receiptDate, 0, 4)}년 ${fn:substring(faultHandling.receiptDate, 4, 6)}월 ${fn:substring(faultHandling.receiptDate, 6, 8)}일 ${fn:substring(faultHandling.receiptDate, 8, 10)}:${fn:substring(faultHandling.receiptDate, 10, 12)}:${fn:substring(faultHandling.receiptDate, 12, 14)}</dd>
					<dd>요청처리일자 : ${fn:substring(faultHandling.processDate, 0, 4)}년 ${fn:substring(faultHandling.processDate, 4, 6)}월 ${fn:substring(faultHandling.processDate, 6, 8)}일 ${faultHandling.dutyHours}</dd>
					<dd>구분 : ${faultHandling.requestType}</dd>
					<dd>의뢰자이름 : ${faultHandling.requesterName}</dd>
					<dd>의뢰자연락처 : ${faultHandling.requesterContactNumber}</dd>
					<dd>A/S 요청장소 : ${faultHandling.requestPlace}</dd>
					<dd>의뢰자 소속 부서명 : ${faultHandling.requesterDepartment}</dd>
					<dd>요청내용 : ${faultHandling.requestContent}</dd>
					<dd>확인증상 및 처리내용 : ${faultHandling.processingInformation}</dd>
					<dd>최초작업자 : ${faultHandling.firstWorkerName} (${faultHandling.firstWorkerContactNumber})</dd>
					<dd><a href="${contextPath}/fault_handling_mod.do?faultHandlingNo=${faultHandling.faultHandlingNo}">수정</a> | <a href="${contextPath}/fault_handling_del.do?faultHandlingNo=${faultHandling.faultHandlingNo}">삭제</a></dd>
				</dl>
			</div>
			<div id="right">	
				<form action="${contextPath}/present_condition.do" method="post">
					<input type="hidden" id="faultHandlingNo" name="faultHandlingNo" value="${faultHandling.faultHandlingNo}" />
					<input type="hidden" id="mode" name="mode" value="insert" />
					<input type="hidden" id="year" name="year" value="${year}" />
					<input type="hidden" id="month" name="month" value="${month}" />
					<input type="hidden" id="dayOfMonth" name="dayOfMonth" value="${dayOfMonth}" />
					
					<dl id="condition_reg" class="wrap">
						<dt class="wrap_title">처리현황 등록</dt>
						<dd>
							작업자 :
							<select id="workerNo" name="workerNo">
								<c:forEach items="${workerList}" var="worker">
									<option value="${worker.workerNo}">${worker.name} (${worker.contactNumber})</option>	
								</c:forEach>
							</select>
						</dd>
						<dd>
							처리현황 <textarea id="content" name="content"></textarea>
						</dd>  
						<dd>
							<input type="submit" value="확인" />
						</dd>
					</dl>	
				</form>
			
				<dl id="condition_list" class="wrap">
					<dt class="wrap_title">처리현황</dt> 
					<dd> 
						<c:forEach items="${presentConditionList}" var="presentCondition">
							<ul id="condition_content">
								<li>
									작업자 : ${presentCondition.workerName} (${presentCondition.workerContactNumber})
								</li>
								<li>
									날짜 : ${fn:substring(presentCondition.date, 0, 4)}년 ${fn:substring(presentCondition.date, 4, 6)}월 ${fn:substring(presentCondition.date, 6, 8)}일 ${fn:substring(presentCondition.date, 8, 10)}:${fn:substring(presentCondition.date, 10, 12)}:${fn:substring(presentCondition.date, 12, 14)} 
								</li>
								<li>
									처리현황 : ${presentCondition.content}
								</li> 
								<li> 
									<a href="${contextPath}/present_condition.do?mode=d&year=${year}&month=${month}&dayOfMonth=${dayOfMonth}&presentConditionNo=${presentCondition.presentConditionNo}&faultHandlingNo=${faultHandling.faultHandlingNo}">삭제</a>
								</li>
							</ul>	
						</c:forEach>
					</dd>
				</dl>
			</div>	
		</c:if>
</body>
</html>